﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess
{
    public class DataAccessProductStore
    {

        public static void InsertProductStore(Model.ProductStore store)
        {
            SSDDEntities.Instance.DiscardChanges();
            SSDDEntities.Instance.ProductStores.Add(store);
        }

        public static void UpdateProductStore(Model.ProductStore store)
        {
            var product = (from p in SSDDEntities.Instance.ProductStores
                           where p.ProductId == store.ProductId
                           select p).First();
            product.StorePriceByUnit = store.StorePriceByUnit;
            product.StoreQuantity = store.StoreQuantity;
    
            SSDDEntities.Instance.SaveChanges();
        }

        public static List<string> GetBranchWithOrders()
        {
            return (from p in SSDDEntities.Instance.Orders
                    where p.Delivered == false
                    select p.BranchRemoteId).ToList();
        }
    }
}
